package com.dingli.admin.controller;

import com.dingli.admin.service.DeleteBank;
import com.dingli.admin.service.FindBankAll;
import com.dingli.admin.service.InsertBank;
import com.dingli.admin.service.UpdateBank;
import com.dingli.framework.entity.Bank;
import com.dingli.framework.util.Response;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/bank")
public class BankController {
    @Autowired
    private FindBankAll findBankAll;

    @Autowired
    private UpdateBank updateBank;

    @Autowired
    private InsertBank insertBank;

    @Autowired
    private DeleteBank deleteBank;

    @GetMapping("/findBankAll")
    private Response<List<Bank>> findBankAll(){
        return findBankAll.findBankAll();
    }

    @GetMapping("/updateBank")
    private Response<Bank> updateBank(Bank bank){
        return updateBank.updateBank(bank);
    }

    @GetMapping("/insertBank")
    public Response<Bank> insert(@Param("bankName") String bankName, @Param("shortName") String shortName, @Param("establishDate" ) Date establishDate){
        return insertBank.insertBanK(bankName,shortName,establishDate);
    }

    @GetMapping("/deleteBank")
    public Response<Bank> delete(@Param("bankId") long bankId){
        return deleteBank.deleteBank(bankId);
    }
}
